﻿using System;
using UnityEngine;

namespace TG
{
    public class VegetableEntity : EntityBase
    {
        public virtual int vitality { get; }

        protected override void Trigger(EntityBase entity)
        {
            if (entity is LambPlayer)
            {
                base.Trigger(entity);
                //删除自己 创建新的
                GameManager.Instance.ResetItem(mapCell.mapItemId, mapItemType, this);
            }
        }

        public void MoveToPlayer(float dis)
        {
            var dir = GameManager.Instance.Player.transform.position - transform.position;

            if (dis < (dir.normalized * Default.VacuumCleanerSpeed).magnitude)
                Trigger(GameManager.Instance.Player);
            else
                transform.position += dir.normalized * Default.VacuumCleanerSpeed;
        }
    }
}